package DebugInformationInput;

public class StrInfoCollection {

	/**
	 * @param args
	 */
	
	public static String[] splitStrOfPresentBp(String str){
		String cls;
		String method;
		String strLineNo;
		int lineNo;
		int posCls;
		posCls=str.indexOf('[',1);
		int posLineBegin=str.indexOf(':', 1);
		int posLineEnd=str.indexOf(']', 1);
		int posMethod=str.indexOf('-', 1);
		System.out.println(posCls+" "+posLineBegin+" "+posLineEnd+" "+posMethod);
		
		cls=str.substring(0,posCls).trim();
		System.out.println(cls+"|length:"+cls.length());
		strLineNo=str.substring(posLineBegin+1, posLineEnd).trim();
		System.out.println("lineno "+strLineNo);
		method=str.substring(posMethod+1).trim();
		System.out.println("method "+method);
		lineNo=Integer.valueOf(strLineNo);
		System.out.println(lineNo);
		//InputDB dataBase=SampleView.getDataBase();
		String[] presentBp=new String[3];
		presentBp[0]=cls.trim();
		presentBp[1]=method.trim();
		presentBp[2]=strLineNo.trim();
		System.out.println("^^^^^^^^^^^^^^^^^^^^^^");
		return presentBp;
		//dataBase.insertIntoInit_BP(cls, method, strLineNo,userName);
		
	}
	
//	public static String[] splitStrOfSuspendedBp(String str){
//		
//	}
	
	
	public static String[] splitStrOfBpPath(String bpProject,String bpFullPath){
		int beginPosProjName=bpProject.indexOf('/', 1)+1;
		String projName=bpProject.substring(beginPosProjName);
		String bpPath=bpFullPath.substring(bpProject.length());
		if(bpPath.startsWith("src")){
			bpPath=bpPath.substring("src/".length());
		}
		String[] str=new String[2];
		str[0]=projName.trim();
		str[1]=bpPath.trim();
		return str;
	}
	
	public static String splitStrOfBpUpdate(String method){
		int posCls=method.indexOf(".",1);
		String clsStr=method.substring(0, posCls).trim();
		//System.out.println(clsStr);
		//InputDB dataBase=SampleView.getDataBase();
		
		return clsStr;
		
		
		//dataBase.insertIntoBP_Update(type, clsStr, method, context, position,userName);
	}
	
	public static String splitStrOfAbortMethod(String cls){
		int posCls;
		posCls=cls.indexOf('.',1);
		String abortClassStr=cls.substring(0,posCls).trim();
		System.out.println(abortClassStr);
	//	InputDB dataBase=SampleView.getDataBase();
		return abortClassStr;
	//	dataBase.insertIntoAbort_Method(abortClassStr, method, context,userName);
		
	}
	
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		//splitStrOfBpUpdate("pack_1.ClsA at localhost:3026","","","","");
		//splitStrOfAbortMethod("ClsB.bMethod() line: 8 <--ClsA.main(String[]) line: 23");
		String[] str=splitStrOfBpPath("P/testproject", "/testproject/src/buaa/mdt/pack2/ClsB.java");
		System.out.println(str[0]+" "+str[0].length());
		System.out.println(str[1]+" ");
	}

	public static String[] splitStrOfSuspendedBp(String suspendLocation) {
		// TODO Auto-generated method stub
		String cls=null;
		String method=null;
		String lineNo=null;
		String[] str=new String[3];
		int classNameEndPos=suspendLocation.indexOf('.', 0);
		cls=suspendLocation.substring(0, classNameEndPos);
		int endOfMethodName=suspendLocation.indexOf("line:");
		method=suspendLocation.substring(classNameEndPos+1, endOfMethodName).trim();
		lineNo=suspendLocation.substring(endOfMethodName+"line:".length()).trim();
		str[0]=cls;
		str[1]=method;
		str[2]=lineNo;
		return str;
	}

}
